home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-25 | 5.2 KB | 105 lines | [TEXT/CCL ] |
- ; (c) Copyright 1990 by University of Massachusetts. All rights reserved.
- ; This software was conceived, designed, and written by Dan Suthers
- ; while supported by the National Science Foundation under grant number
- ; MDR 8751362, and by a fellowship from Apple Computer, Inc., Cupertino,
- ; CA. Partial support was also received from the Office of Naval Research
- ; under a University Research Initiative Grant, contract N00014-86-K-0764.
- ; Mr. Suthers created this software under his own initiative while in an
- ; academic relationship with the University of Massachusetts. The above
- ; copyright notice was a condition placed by University lawyers on approval
- ; of distribution of this software by Apple Computer, and is not meant to
- ; imply that this software was created in an employment or "work for hire"
- ; relationship between the University and Mr. Suthers.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; File: MATH.lisp
- ; Author: Dan Suthers
- ; Created: 16-Jun-88 10:32:58
- ; Modified: 22-Jun-90 02:04:23 (Dan Suthers)
- ; Language: Common Lisp
- ; Package: UTILS
- ;
- ; Description: Math utilities: averaging, interpolation, coordinate conversion.
- ;
- ; (c) Copyright 1988, by Daniel D. Suthers
- ; Department of Computer and Information Science
- ; University of Massachusetts
- ; Amherst, Massachusetts 01003
- ;
- ; This software was conceived, designed, and written by Dan Suthers
- ; while supported by the National Science Foundation under grant number
- ; MDR 8751362, and by a fellowship from Apple Computer, Inc., Cupertino,
- ; CA. Partial support was also received from the Office of Naval Research
- ; under a University Research Initiative Grant, contract N00014-86-K-0764.
- ; I wish to acknowledge the generous support of Beverly Woolf, who obtained
- ; the above grants and encouraged me to pursue my own research interests in
- ; her lab. This work would not have been possible without the resources and
- ; stimulating environment of the Computer and Information Science department.
- ;
- ; Permission to use, modify, and distribute this software is granted subject
- ; to the following restrictions and understandings:
- ; 1. The file header, including this notice, shall be retained, and may be
- ; extended to include documentation of modifications to the software.
- ; 2. This material is for nonprofit educational and research purposes only.
- ; Users are requested, but not required, to inform Mr. Suthers of any
- ; noteworthy uses of this software.
- ; 3. Mr. Suthers and the University of Massachusetts make no warrantee or
- ; representation that the operation of this software will be error free,
- ; and are under no obligation to provide any services.
- ; 4. Any user of such software agrees to indemnify and hold harmless Mr.
- ; Suthers and the University of Massachusetts from all claims arising
- ; out of the use or misuse of this software, or arising out of any
- ; accident, injury, or damage whatsoever, and from all costs, counsel
- ; fees, and liabilities incurred in or about any such claim, action, or
- ; proceeding brought thereon.
- ; 5. All materials and reports developed as a consequence of the use of
- ; this software shall duly acknowledge such use, in accordance with
- ; the usual standards of acknowledging credit in academic research.
-
- ;
- ; Status: Done and tested.
- ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (in-package :UTILS)
-
- (export '(
- degrees
- exponential-average
- linear-interpolation
- radians
- ))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defun EXPONENTIAL-AVERAGE (decay-rate new-value old-value)
- "exponential-average <decay-rate> <new-value> <old-value> [Function]
- Computes the classic formula for an incremental exponential average:
- average(0) = 0
- average(t+1) = decay-rate*value(t) + (1 - decay-rate)*average(t)"
- (+ (* decay-rate new-value) (* (- 1.0 decay-rate) old-value)))
-
- (defun LINEAR-INTERPOLATION (low-x low-y val high-x high-y)
- "linear-interpolation <x1> <f(x1)> <x'> <x2> <f(x2)> [Function]
- Assume you have a function where f(<x1>) = <f(x1)> and f(<x2>) = <f(x2)>.
- Given an <x'> where <x1> <= <x'> <= <x2>, does linear interpolation using:
- <f(x1)> + [(<x'> - <x1>) / (<x2> - <x1>)] * [<f(x2)> - <f(x1)>]
- to estimate the value of f(<x'>) and returns the floating point result."
- (+ (float low-y) ; Height of baseline
- (* (- (float high-y) (float low-y)) ; Maximum height above baseline
- (/ (- (float val) (float low-x)) ; Ratio expression of how far
- (- (float high-x) (float low-x)) )))) ; val is along base line.
-
- (defmacro RADIANS (angle)
- "radians <angle> [Macro]
- Converts degrees to radians."
- `(* ,angle (/ pi 180.0)))
-
- (defmacro DEGREES (radian)
- "degrees <radian> [Macro]
- Converts radians to degrees."
- `(* ,radian (/ 180.0 pi)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (provide :MATH)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;; EOF